#include <QApplication>
#include <QmainWindow>
#include <qgsmapcanvas.h> 
#include <qgsrasterlayer.h>
#include <qgsmaptoolpan.h>
#include <qgsapplication.h>
#include <qgsvectorlayer.h>

#pragma comment(lib, "qgis_core.lib")
#pragma comment(lib, "qgis_gui.lib")
#pragma comment(lib, "qgis_app.lib")

/**
* #pragma comment(lib, "qgis_core.lib") 等同 项目属性/链接/输入/附加依赖项设置
* qgis_app.lib
qgis_gui.lib
qgis_core.lib
gdal-dev312.lib
zlib.lib
*/


int main(int argc, char** argv) {
	QgsApplication qgsApp(argc, argv, true);
    QgsApplication::setPrefixPath(R"(D:\OSGeo4W\apps\qgis-qt6-dev)", true);
    QgsApplication::initQgis();

	QString shpPath = R"(D:\data\shp\nyc_census_blocks.shp)";
    QgsVectorLayer* layer = new QgsVectorLayer(shpPath, "nyc_census_blocks", "ogr");
    if (!layer->isValid()) {
        qDebug() << "Layer failed to load!" << layer->error().message();
        qgsApp.exitQgis();
        return -1;
    }
    QgsMapCanvas mapCanvas;
    mapCanvas.setLayers({layer});
    mapCanvas.zoomToFullExtent();
    mapCanvas.setWindowTitle("QGIS二次开发");
    mapCanvas.resize(800, 600);
    mapCanvas.show();
    qgsApp.exec();
    qgsApp.exitQgis();
    return 0;
}